<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div class="box"></div>

  <script>
    // html文档的加载顺序是自上而下的 如果将js放在上方 会无法获取到 .box
    var boxEl = document.querySelector(".box")
  </script>
</body>
</html>